{% load custom_admin_tags %}

<tr>
    <td>
        {% if level > 0 %}
            {% for i in level|range_filter %}
                &nbsp;&nbsp;&nbsp;&nbsp;
            {% endfor %}
            <i class="fas fa-level-up-alt fa-rotate-90 text-muted me-1"></i>
        {% endif %}
        {{ category.name }}
    </td>
    <td>{{ category.code }}</td>
<td>{{ category.description|truncatewords:10 }}</td>
    <td>
        <div class="btn-group" role="group">
            <a href="{% url 'custom_admin:category_create' %}?parent={{ category.pk }}" class="btn btn-sm btn-outline-success">
                <i class="fas fa-plus-circle"></i> 子分类
            </a>
            <a href="{% url 'custom_admin:category_edit' category.pk %}" class="btn btn-sm btn-outline-primary">
                <i class="fas fa-edit"></i> 编辑
            </a>
            <a href="{% url 'custom_admin:category_delete' category.pk %}" class="btn btn-sm btn-outline-danger">
                <i class="fas fa-trash"></i> 删除
            </a>
        </div>
    </td>
</tr>

{% for child in category.get_children %}
    {% include "custom_admin/category_tree.html" with category=child level=level|add:1 %}
{% endfor %}